//
//  CNSearchResultCollectionViewCell.m
//  BeeQuick_19
//
//  Created by kimi on 16/9/23.
//  Copyright © 2016年 CN Team. All rights reserved.
//

#import "CNSearchResultCollectionViewCell.h"
#import "CNHotSearchModel.h"
#import "ParabolaTool.h"
#import "CNUserShopCarTools.h"
@interface CNSearchResultCollectionViewCell ()

//名称
@property (weak, nonatomic) IBOutlet UILabel *nameLabel;
//规格
@property (weak, nonatomic) IBOutlet UILabel *specificsLabel;
//优惠后的价格
@property (weak, nonatomic) IBOutlet UILabel *priceLabel;
//超市价格
@property (weak, nonatomic) IBOutlet UILabel *market_priceLabel;
//显示购买数量
@property (weak, nonatomic) IBOutlet UILabel *numCountLabel;
//减少Btn
@property (weak, nonatomic) IBOutlet UIButton *minusButton;

@end

@implementation CNSearchResultCollectionViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
}
//加
- (IBAction)incressBtnClick:(id)sender {

    if (self.incCountBlock) {
        self.incCountBlock();
    }

    //做动画
    if ([self.delegate respondsToSelector:@selector(shopDetailOrderFoodCell:didClickAddButton:)]){
        [self.delegate shopDetailOrderFoodCell:self didClickAddButton:sender];
    }
    
    [[SQLiteManager sharedSQLiteManager] charu:self.hotSearchModel With:1];

}
//减
- (IBAction)minusBtnClick:(id)sender {


    //回调count
    if (self.desCountBlock) {
        self.desCountBlock();
    }
    
    [[SQLiteManager sharedSQLiteManager] charu:self.hotSearchModel With:-1];
}


-(void)setHotSearchModel:(CNHotSearchModel *)hotSearchModel
{
    _hotSearchModel = hotSearchModel;
    
    if (self.hotSearchModel.count == 0) {
        self.numCountLabel.hidden = true;
        self.minusButton.hidden = true;
    }else{
        self.numCountLabel.hidden = false;
        self.minusButton.hidden = false;
    }
    
    //1. 设置图像
    [self.img sd_setImageWithURL:[NSURL URLWithString:hotSearchModel.img] placeholderImage:[UIImage imageNamed:@"v2_placeholder_square"]];
    
//    _hotSearchModel.pageCount = hotSearchModel.count;
    
    //2.设置标题
    self.nameLabel.text = hotSearchModel.name;
    //3.设置描述
    self.specificsLabel.text = hotSearchModel.specifics;
    //4.设置价格
    self.priceLabel.text = [NSString stringWithFormat:@"¥%@",hotSearchModel.price];
    //5.设置超市价格
    self.market_priceLabel.text = [NSString stringWithFormat:@"¥%@",hotSearchModel.market_price];
    //设置num
    self.numCountLabel.text = [NSString stringWithFormat:@"%zd",self.hotSearchModel.count];
}



@end
